(function(KKBus){

    function UserController() {
        var self = this;
        self.user;
        self.user = ko.observableArray();
        
        self.getUser = function (page)
        {
            //self.historylog.removeAll();
            
            app.request++;
        
             var url = 'rest/users/USER';
             
             if (page > 0) {
                
                
            }
                                 
           
        
        
        KKBus.Ajax.doGet(url, function(data, textStatus, jqXHR)
        {
      
        var jsData = JSON.parse(data);
        var i = jsData.length;
        
        
            while(i--){
                 self.user.push(new KKBus.UserModel(jsData[i].id,jsData[i].name,jsData[i].surname )); 
         }
         app.request--;
                  
          if (app.request == 0) {
                    if (app.settings.DEBUG == true) { console.log("Load template from: " +  UserController.name); }
                    setTimeout(function() { app.loadTemplate(); }, 1000);
                }
            });
        };
        
//      self.deleteUser = function(id, index) {
//            var users = app.Knockout.UserController.user()[index];
//            
//            var koles = app.Knockout.AuthenticationController.user;
//            var userId = koles.id();
//           
//                var deleteU = JSON.stringify({
//                    
//                    idUser: id,
//                    idUsers: userId
//                });  
//           
//                KKBus.Ajax.doDelete('rest/user'+id, deleteU, function(result, textStatus, jqXHR) {
//                    if (result == "ADDED") {
//                        users.delete;
//                        console.log('dziala');
//                        
//                      
//                    }  
//                });
//            } 
        }
        
    
    
    
    
   

    KKBus. UserController =  UserController;
    
}(window.KKBus));

